# 更深层嵌套
from typing import List, Optional, Set

import uvicorn
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


# 模型一
class Image(BaseModel):
    url: str
    name: str


# 模型二
class Item(BaseModel):
    name: str
    price: float
    tags: Optional[Set[str]] = set()
    images: Optional[List[Image]] = None


# 模型三
class Offer(BaseModel):
    name: str
    description: Optional[str] = None
    items: List[Item]


@app.post("/offers/")
async def create_offer(offer: Offer):
    return offer


'''
{
    "name": "string",
    "description": "string",
    "items": [
        {
            "name": "string",
            "price": 0,"tags": [],
            "images": [
                {
                    "url": "string",
                    "name": "string"
                }
            ]
        }
    ]
}
'''

if __name__ == "__main__":
    uvicorn.run(app="main3:app", host="127.0.0.1", port=8000, reload=True, debug=True)